/*
 * Park.java
 */
package model;

/**
 * Park represents a park in the Urban Parks program.
 * 
 * @author Carlo Consolacion
 * @author Sean Brown
 * @version 2.0
 */
public class Park implements Cloneable {

	/**
	 * The name of the park.
	 */
	private final String my_name;

	/**
	 * The phone number for the park.
	 */
	private final PhoneNumber my_phone_number;

	/**
	 * The ID value of the park.
	 */
	private final int my_id;

	/**
	 * The ID of the User who is the Park Manager for this park.
	 */
	private final int my_park_manager_id;

	/**
	 * The address of this park.
	 */
	private final PostalAddress my_postal_address;

	/**
	 * The district of this park.
	 */
	private final String my_district;

	/**
	 * The region of this park.
	 */
	private final String my_region;

	/**
	 * Constructor creates a new Park object and assigns values to all fields.
	 * 
	 * @assumes all values are non null.
	 * @param the_name
	 *            The name of this park.
	 * @param the_address
	 *            The address of this park.
	 * @param the_phone_number
	 *            The phone number of this park.
	 * @param the_park_manager_id
	 *            The ID of the manager for this park.
	 * @param the_district
	 *            The district of this park.
	 * @param the_region
	 *            The region of this park.
	 */
	public Park(final String the_name, final PostalAddress the_address,
			final PhoneNumber the_phone_number, final int the_park_manager_id,
			final String the_district, final String the_region) {
		my_name = the_name;
		my_postal_address = the_address;
		my_phone_number = the_phone_number;
		my_park_manager_id = the_park_manager_id;
		my_district = the_district;
		my_region = the_region;
		my_id = hashCode();
	}

	/**
	 * Getter method for the park name.
	 * 
	 * @return String the park name.
	 */
	public String getName() {
		return my_name;
	}

	/**
	 * Getter method for the address of this park.
	 * 
	 * @return PostalAddress the park's address.
	 */
	public PostalAddress getAddress() {
		return my_postal_address;
	}

	/**
	 * Getter method for the park's phone number.
	 * 
	 * @return PhoneNumber The park's phone number.
	 */
	public PhoneNumber getPhoneNumber() {
		return my_phone_number;
	}

	/**
	 * Getter method for the ID of this park. (generated via the hashCode
	 * method).
	 * 
	 * @return int The park's ID number.
	 */
	public int getID() {
		return my_id;
	}

	/**
	 * Getter method for the ID of this park's manager.
	 * 
	 * @return int The park manager's ID number.
	 */
	public int getManagerID() {
		return my_park_manager_id;
	}

	/**
	 * The district of the park.
	 * 
	 * @return String the park's district.
	 */
	public String getDistrict() {
		return my_district;
	}

	/**
	 * The region of the park.
	 * 
	 * @return String The park's region.
	 */
	public String getRegion() {
		return my_region;
	}

	/**
	 * Overridden toString method for a Park. Returns a String representation of
	 * the information that makes this Park object unique. (name, address,
	 * district, region, phone number).
	 * 
	 * @return String representation of this Park.
	 */
	@Override
	public String toString() {
		final String nl = "\n";
		StringBuilder sb = new StringBuilder();
		sb.append("Park Name: ");
		sb.append(my_name);
		sb.append(nl);
		sb.append("Address: ");
		sb.append(my_postal_address.toString());
		sb.append(nl);
		sb.append("District: ");
		sb.append(my_district);
		sb.append(", Region: ");
		sb.append(my_region);
		sb.append(nl);
		sb.append("Phone Number: ");
		sb.append(my_phone_number.toString());
		return sb.toString();
	}

	/**
	 * Overridden hashCode method, returns the integer value for this object
	 * (via the toString method).
	 * 
	 * @return int the hashCode for this Park.
	 */
	@Override
	public int hashCode() {
		return toString().hashCode();
	}

	/**
	 * Overridden equals method for this Park. Returns true when the objects are
	 * both Park objects and have the same hashCode values.
	 */
	@Override
	public boolean equals(final Object obj) {
		boolean equal = false;
		if (obj != null && getClass() == obj.getClass()) {
			equal = ((Park) obj).hashCode() == hashCode();
		}
		return equal;
	}

	/**
	 * Overridden clone method for this Park. Returns an immutable replica of
	 * this Park.
	 */
	@Override
	public Object clone() {
		Park result = new Park(my_name,
				(PostalAddress) my_postal_address.clone(),
				(PhoneNumber) my_phone_number.clone(), my_park_manager_id,
				my_district, my_region);
		return result;
	}
}
